<?php

/**
 * persona form.
 *
 * @package    sistema_itec_new
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class personaForm extends BasepersonaForm {

    public function configure() {

        $sexos = array('M' => 'HOMBRE', 'F' => 'MUJER');
        $tipos_sangre = array('0-', '0+', 'A-', 'A+', 'B-', 'B+', 'AB-', 'AB+');
        $tipos_sangre = array_combine($tipos_sangre, $tipos_sangre);

        $this->widgetSchema['sexo'] = new sfWidgetFormChoice(array('choices' => $sexos));
        $this->widgetSchema['tipo_sangre'] = new sfWidgetFormChoice(array('choices' => $tipos_sangre));
        $this->widgetSchema['fecha_nacimiento'] = new sfWidgetFormInputText();
        $this->widgetSchema['localidad_id'] = new sfWidgetFormDoctrineJQueryAutocompleter(array(
            'url' => sfContext::getInstance()->getController()->genUrl('ajax/localidad'),
            'model' => 'Localidad',
            'value_callback' => 'findOneById'
        ));
        $this->widgetSchema['localidad_nacimiento_id'] = new sfWidgetFormDoctrineJQueryAutocompleter(array(
            'url' => sfContext::getInstance()->getController()->genUrl('ajax/localidad'),
            'model' => 'Localidad',
            'value_callback' => 'findOneById'
        ));
        $this->widgetSchema['nacionalidad_id'] = new sfWidgetFormDoctrineJQueryAutocompleter(array(
            'url' => sfContext::getInstance()->getController()->genUrl('ajax/nacionalidad'),
            'model' => 'Nacionalidad',
            'value_callback' => 'findOneById'
        ));
        $this->widgetSchema['foto'] = new sfWidgetFormInputFileEditable(array(
                    'file_src' => '/uploads/fotos_personas/' . ($this->getObject()->getFoto() ? $this->getObject()->getFoto() : 'default_avatar.png'),
                    'is_image' => true,
                    'edit_mode' => $this->getObject()->getFoto(),
                    'delete_label' => 'Eliminar',
                    'template' => '<div class="resized-picture-parent">%file%<br />%input%<br />%delete% %delete_label%</div>',
                ));
        $this->widgetSchema['barrio_id'] = new sfWidgetFormDoctrineJQueryAutocompleter(array(
            'url' => sfContext::getInstance()->getController()->genUrl('ajax/barrio'),
            'model' => 'Barrio',
            'value_callback' => 'findOneById'
        ));
        $this->widgetSchema['fecha_censo'] = new sfWidgetFormInputHidden();
        $this->widgetSchema['usuario_id'] = new sfWidgetFormInputHidden();


        $this->validatorSchema['foto'] = new sfValidatorFile(array(
                    'required' => false,
                    'path' => sfConfig::get('sf_upload_dir') . '/fotos_personas',
                    'mime_types' => 'web_images',
                ));
        $this->validatorSchema['foto_delete'] = new sfValidatorPass();
        
        $this->validatorSchema->setOption('allow_extra_fields', true);
    }

}
